import { createRouter, createWebHistory } from "vue-router";
import HomeView from "../views/HomeView.vue";
import adminRoutes from "./adminRoutes";
import nurseRoutes from "./nurseRoutes";
import commonRoutes from "./commonRoutes";

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: "/",
      name: "home",
      children: [...adminRoutes, ...commonRoutes],
      component: () => import("@/views/HomeView.vue"),
    },
    {
      path: "/login",
      name: "login",
      component: () => import("@/views/login/login.vue"),
    },
  ],
});

router.beforeEach((to, from, next) => {
  document.title = to?.meta?.title || "养老院管理系统";
  next();
  // if (to.path === "/") {
  //   next("/login");
  // } else {
  //   next();
  // }
});

export default router;
